const path = require('path');
const log4js = require("log4js");

if (process.env.WINSW_SERVICE_ID) { // 服务模式
	log4js.configure({
		appenders: {
			console: { type: 'console' },
		},
		categories: {
			default: { appenders: [ 'console' ], level: 'debug' }
		}
	});
} else { // 窗口模式
	log4js.configure({
		appenders: {
			file: { type: 'dateFile', filename: path.join(process.cwd(), '/console/common.log'), numBackups: 31 },
			console: { type: 'console' },
		},
		categories: {
			default: { appenders: [ 'file', 'console' ], level: 'debug' }
		}
	});
}
const logger = log4js.getLogger();

module.exports = {
	log4js,
	logger,
};
